#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
int main()
{
	int n = 0;
	int m = 0;
	int mid = 0;
	int sum = 0;
	int i = 0;
	int j = 0;
	int arr[10] = { 0 };

	scanf("%d %d", &n,&m);
	for(i = n;i <= m;i++)
	{
		int x = i;
		while (x)
		{
			mid = x % 10;
			x /= 10;
			sum += pow(mid, 4);
		}
		if (sum == i)
		{
			arr[j++] = i;
		}
		sum = 0;
	}
	for (i = 0; i < j; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}